﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;

namespace MetadataBasedConfig.Web
{
    public class TestHttpModule:IHttpModule
    {
        public void Dispose()
        { 
        }

        public void Init(HttpApplication context)
        {
            //context.MapRequestHandler += new EventHandler(context_MapRequestHandler);
            context.PostMapRequestHandler += new EventHandler(context_PostMapRequestHandler); 
        }

        protected void context_PostMapRequestHandler(object sender, EventArgs e)
        {
            //HttpApplication application = sender as HttpApplication;
            //var handler =  application.Context.Handler;
            //if (handler is ITest)
            //{
            //    application.Response.Write("ddddd");
            //    application.Response.End();
            //}
        }

        void context_MapRequestHandler(object sender, EventArgs e)
        {

        }
    }

    public class TestRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            requestContext.HttpContext.Items.Add("Test","dddddd");
            return new TestHttpHandler();
        }

        internal class TestHttpHandler : IHttpHandler
        {
            public bool IsReusable
            {
                get { return false; }
            }

            public void ProcessRequest(HttpContext context)
            {
                //context.Response.Redirect("test.aspx");
            }
        }
    }
}